package com.xudow.app.newui.adapter;

import android.graphics.Color;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xudow.app.R;
import com.xudow.app.newui.bean.FuJin2;
import com.xudow.app.newui.bean.TownEntity;

import java.util.List;

/**
 * 作者：LownChen on 2016/9/2 16:20
 */
public class FuJin2Adapter extends BaseAdapter{


    FragmentActivity activity;
    List<TownEntity> list1;

    public FuJin2Adapter(FragmentActivity activity, List<TownEntity> list1) {

        this.activity=activity;
        this.list1=list1;

    }
    int i=-1;


    public void NoAdapter(int i, FuJin2Adapter adapter, List<TownEntity> list1){
         this.list1=list1;
         this.i=i;
         adapter.notifyDataSetChanged();

      }
    @Override
    public int getCount() {
        return list1.size();
    }

    @Override
    public Object getItem(int position) {
        return list1.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
        if(convertView==null){
            convertView= LayoutInflater.from(activity).inflate(R.layout.item_course_filter_menu,null);
            holder=new ViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            holder=(ViewHolder)convertView.getTag();
        }
        if(i==position){

            holder.name.setText(list1.get(position).getName());
            holder.name.setTextColor(Color.parseColor("#068600"));
            holder.icon.setVisibility(View.VISIBLE);
        }else{
            holder.name.setText(list1.get(position).getName());
            holder.name.setTextColor(Color.parseColor("#000000"));
            holder.icon.setVisibility(View.GONE);
        }

        return convertView;
    }
    class ViewHolder{

        TextView name;
        ImageView icon;

        public ViewHolder(View convertView) {

            name=(TextView)convertView.findViewById(R.id.name);
            icon=(ImageView)convertView.findViewById(R.id.icon);
        }
    }
}
